package com.trnnn.renren1.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.renren1.session.SessionFactory;
import com.trnnn.renren1.config.AppConfig;
import com.trnnn.renren1.logic.UserManager;

/**
 * Servlet implementation class Index
 */
@WebServlet("/index")
public class Index extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public Index() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		initSession(request, response);
		UserManager.getInstance().executeUserInfo();
		UserManager.getInstance().executePhotos();
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	}

	private void initSession(HttpServletRequest request,
			HttpServletResponse response) {
		SessionFactory.REQUEST.set(request);
		SessionFactory.RESPONSE.set(response);
		request.setAttribute("appId", AppConfig.renrenAppID);

	}
}
